#include "CEGuiSample.h"
#include "CEGUI.h"
#include "AnimationSakura.h"
#include<string>

SakuraRain::SakuraRain(){};

SakuraRain::SakuraRain(CEGUI::Window* areaWindow,CEGUI::Window* imageWindow,std::string ani_name1,std::string ani_name2)
		:_areaWindow(areaWindow),_imageWindow(imageWindow),aniname1(ani_name1),aniname2(ani_name2)
{
		_imageWindow->subscribeEvent(_ani2->EventAnimationEnded,CEGUI::Event::Subscriber(&SakuraRain::handleDestroy,this));	
		_areaWindow->addChildWindow(_imageWindow);
		animation1 = CEGUI::AnimationManager::getSingleton().getAnimation(aniname1);
		_ani1 = CEGUI::AnimationManager::getSingleton().instantiateAnimation(animation1);
		animation2 = CEGUI::AnimationManager::getSingleton().getAnimation(aniname2);
		_ani2 = CEGUI::AnimationManager::getSingleton().instantiateAnimation(animation2);	
		_ani1->setTargetWindow(_imageWindow);
		_ani1->start();
		_ani1->setSpeed(1);
		_ani2->setTargetWindow(_imageWindow);
		_ani2->start();
		_ani2->setSpeed(1);
		
		
};

bool SakuraRain::handleDestroy(const CEGUI::EventArgs &e){
  	_imageWindow->setVisible(false);
	return true;
}

void SakuraRain::setSpeed(float s){
	speed  = s;
	_ani1->setSpeed(s);
	_ani2->setSpeed(s);
}